﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Kocic.RepositoryManagement
{
    /// <summary>
    /// Defines information pertaining to the events that were invoked for a particular data object.
    /// </summary>
    /// <typeparam name="TDataObject">The type of the data object that will be stored in the event arguments.</typeparam>
    public class DataObjectEventArgs<TDataObject> : EventArgs
    {
        /// <summary>
        /// Creates an instance of the DataObjectEventArgs class.
        /// </summary>
        public DataObjectEventArgs()
        {

        }

        /// <summary>
        /// Gets or sets the data object.
        /// </summary>
        public TDataObject DataObject
        {
            get;
            set;
        }
    }

    /// <summary>
    /// Helper class for creating new instances of the DataObjectEventArgs class.
    /// </summary>
    /// <typeparam name="T">The type of the data object that will be stored in the event arguments.</typeparam>
    internal static class DataObjectEventArgsFactory<T>
        where T : class
    {
        /// <summary>
        /// Returns an instance of DataObjectEventArgs class.
        /// </summary>
        /// <param name="dataObject">The data object to set.</param>
        /// <returns>An instance of the DataObjectEventArgs class.</returns>
        public static DataObjectEventArgs<T> Create(T dataObject)
        {
            return new DataObjectEventArgs<T>() { DataObject = dataObject };
        }
    }
}